﻿<div class="wrap-container">
    <form class="layui-form" style="width: 80%;padding-top: 20px;">
        <div class="layui-form-item">
            <label class="layui-form-label">名称：</label>
            <div class="layui-input-block">
                <input type="hidden" name="Parentid" />
                <input type="text" name="Pname" required lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary" onclick="cleartext()">重置</button>
            </div>
        </div>
    </form>
</div>
@section script{
<script>
	//Demo
	layui.use(['form'], function() {
		var form = layui.form();
		form.render();
		//监听提交
		form.on('submit(formDemo)', function(data) {
			//layer.msg(JSON.stringify(data));
			AddParent();
			//parent.layer.msg('Hi, man');
			return false;
		});
	});
	function AddParent(){
		var data={Parentid:$("input[name='Parentid']").val(),Pname:$("input[name='Pname']").val()};
		$.ajax({
			type:"post",
			url:"/Home/addparent",
			data: data,
			dataType:'Json',
			//async:true,
			success:function(data){
				parent.layer.msg(data);
			}
		});
	}
	function cleartext(){
		$("input[name='Pname']").val("");
	}
	
</script>
}
